/**
 * 面包屑标题栏中显示到详情页面
 */

export default function (title) {
  return function (target) {
    const { componentWillMount, componentWillUnmount } = target.prototype;
    target.prototype.componentWillMount = function () {
      const { dispatch } = this.props;
      if (componentWillMount) componentWillMount.call(this);
      dispatch({
        type: 'app/showSecondBread',
        secondBread: title,
      });
    };
    target.prototype.componentWillUnmount = function () {
      const { dispatch } = this.props;
      if (componentWillUnmount) componentWillUnmount.call(this);
      dispatch({
        type: 'app/showSecondBread',
        secondBread: ''
      });
    };
  };
}
